package com.gite.nouette.admin.implementation.data;

import java.util.HashMap;
import java.util.Map;

import com.gite.nouette.admin.contract.data.IJsonRpcRequest;
import com.gite.nouette.admin.contract.service.IVisitorData;

public class JsonRpcRequest implements IJsonRpcRequest {
	private String jsonrpc;
	private String method;
	private Map<String, Object> params;
	private String id;

	public JsonRpcRequest() {
		setParams(new HashMap<String, Object>());
	}

	public JsonRpcRequest(String jsonrpc, String method, Map<String, Object> params, String id) {
		setJsonrpc(jsonrpc);
		setMethod(method);
		setParams(params);
		setId(id);
	}

	@Override
	public String getJsonrpc() {
		return jsonrpc;
	}

	@Override
	public void setJsonrpc(String jsonrpc) {
		this.jsonrpc = jsonrpc;
	}

	@Override
	public String getMethod() {
		return method;
	}

	@Override
	public void setMethod(String method) {
		this.method = method;
	}

	@Override
	public Map<String, Object> getParams() {
		return params;
	}

	@Override
	public void setParams(Map<String, Object> params) {
		this.params = params;
	}

	@Override
	public <V> void putParam(String key, V value) {
		getParams().put(key, value);
	}

	@Override
	@SuppressWarnings("unchecked")
	public <V> V getParam(String key) {
		return (V) getParams().get(key);
	}

	@Override
	public String getId() {
		return id;
	}

	@Override
	public void setId(String id) {
		this.id = id;
	}

	@Override
	public void accept(IVisitorData visitor) {
		visitor.visitJsonRpcRequest(this);
	}

}
